﻿using System;
using System.Collections.Generic;
using System.Text;

namespace EasyFramework.Base
{
    /// <summary>
    /// 单例基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseSingleton<T> where T : class, new()
    {
        private static object obj = new object();
        private static T m_instance = null;

        public static T Instance
        {
            get
            {
                if (m_instance == null)
                {
                    lock (obj)
                    {
                        if (m_instance == null)
                        {
                            m_instance = new T();
                        }
                    }
                }
                return m_instance;
            }
        }
    }
}
